﻿/* Filename: ElementType.as 
 *
 * Description: This class contains element
 * types and the methods for accessing/mutating
 * them.  Attack, Demon, and Tile classes extend
 * 
 *
 * Tyler Samson
 * Feb 2008
 * @ Sierra Nevada College
 */
class ElementType {
	// Create the enumerated values for each element type
	public static var _elementTypes:EnumeratedType =
					new EnumeratedType("fire", "water", "air", "grass", "rock", "electric");
	public static var _typeDisadvantages:EnumeratedType = new EnumeratedType("water", "grass", "electric", "fire", "air", "rock");
	
	public var _elementType:Number;
	
	public function ElementType(p_elementType:String) {
		_elementType = _elementTypes[p_elementType];	// Set this object's element type when instantiating
	}
	
	
	// Return true if the attack's element type matches the parameter
	public function isElementType(p_elementType:String):Boolean {
		var returnValue:Boolean = false;
		
		if (_elementType == _elementTypes[p_elementType]) {
			returnValue = true;
		}
		
		return returnValue;
	}
	
	// Returns the name of the attack's element type for printing
	public function getElementType():String {
		return _elementTypes[_elementType];
	}
	
	public function hasTypeAdvantage(p_elementType:String):Boolean {
		var returnValue:Boolean = false;
		
		if (_elementTypes[p_elementType] == _elementType) {
			returnValue = true;
		}
		return returnValue;
	}
	
	public function hasTypeDisadvantage(p_elementType:String):Boolean {
		var returnValue:Boolean = false;
		var _typeDisadvantage:String = _typeDisadvantages[p_elementType];		// get the type this has an advantage over
		
		if (_elementTypes[_elementType] == _elementTypes[_typeDisadvantage]) {
			returnValue = true;
		}
		
		return returnValue;
	}
}